<?php

function secureEmail($email){
  return preg_match('/^\S+@[\w\d.-]{2,}\.[\w]{2,6}$/iU', $email) ? TRUE : FALSE;
}

function secureString($string, $type, $minlength, $maxlength){

  	// assign the type
  	$type = 'is_'.$type;
	if(!$type($string))
    {
    	return FALSE;
    } elseif(empty($string)) {
    	return FALSE;
    } elseif(strlen($string) > $maxlength) {
    	return FALSE;
    } elseif(strlen($string) < $minlength) {
    	return FALSE;
    } else {
    	return addslashes($string);
    }
}

function secureNumber($number, $type, $minvalue, $maxvalue){

  	// assign the type
  	$type = 'is_'.$type;
	if(!$type($number))
    {
    	return FALSE;
    } elseif(empty($number)) {
    	return FALSE;
    } elseif($number > $maxvalue) {
    	return FALSE;
    } elseif($number < $minvalue) {
    	return FALSE;
    } else {
    	return $number;
    }
}

function secureBoolean($boolean, $type){

  	// assign the type
  	$type = 'is_'.$type;
	if(!$type($boolean))
    {
    	return FALSE;
    } elseif(empty($boolean)) {
    	return FALSE;
    } else {
    	return $boolean;
    }
}
?>